/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-01-12 09:35:49
 * @LastEditTime : 2023-08-11 16:52:59
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\TwoRouter\Flow.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, DelDataButton, ModDataButton } from '../Common/options'
import { UserGroup } from '../Common/Conversion'

export const Flow = async ({ OptionsEvent, oneData, Permission, actionRef }) => {
    const UserGroupData = await UserGroup()
    let data = {
        pageSize: 10,
        hideInSearch: true,
        params: { flowUuid: oneData.uuid },
        initialValues: { flowUuid: oneData.uuid, tableName: oneData.tableName },
        get: API_LIST()['getFlowDetail'],
        added: 'posFlowDetail',
        modify: `putFlowDetail`,
        options: [<AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'flowUuid',
                title: 'flowUuid',
                valueType: 'hidden',
                hideInTable: true,
            },
            {
                dataIndex: 'tableName',
                title: '流程名称',
                valueType: 'hidden',
                ellipsis: true,
                width: 100,
            },
            {
                dataIndex: 'sortId',
                title: '流程顺序',
                valueType: 'inputNumber',
                ellipsis: true,
                rules: true,
                width: 100,
            },
            {
                dataIndex: 'approvalCondition',
                title: '审批条件',
                valueType: 'input',
                pattern: '[0-9]*',
                tooltip: '如果审批类型不是是“按表单中金额审批”,则审批填0。由配置人员填写数据,都是小于等',
                ellipsis: true,
                rules: true,
                width: 100,
            },
            {
                dataIndex: 'approvalType',
                title: '审批类型',
                rules: true,
                valueType: 'select',
                ellipsis: true,
                width: 100,
                valueEnum: BuiltInData.approvalType,
            },
            {
                dataIndex: 'approvalRule',
                title: '审批规则',
                rules: true,
                valueType: 'select',
                ellipsis: true,
                width: 100,
                valueEnum: BuiltInData.approvalRule,
            },
            {
                dataIndex: 'userGroupUuid',
                title: '审批通过步骤',
                valueType: 'select',
                ellipsis: true,
                rules: true,
                valueEnum: UserGroupData,
            },
            {
                dataIndex: 'noUserGroupUuid',
                title: '审批失败步骤',
                valueType: 'select',
                ellipsis: true,
                rules: true,
                valueEnum: UserGroupData,
            },
            {
                dataIndex: 'approvalDay',
                title: '审批天数',
                valueType: 'inputNumber',
                tooltip: '0表示不限制',
                ellipsis: true,
                rules: true,
                width: 100,
            },
            commonTableList.remark,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 220,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url="FlowDetail"
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }
    return data
}
